<?php

class pubController extends Controller
{
	/**
	 * 用户登陆页面
	 */
	public function login() {
		if(!empty($_POST)) {
			if(!ProofHelper::compare(fetch_a_char('va'))){
				Show::warn('验证码输入有误');
			}
			ProofHelper::clear();
			$username	= strtolower(fetch_a_string('username'));
			$password	= fetch_a_char('password');
			if($username && $password) {
				if(UserAuthHelper::doLogin($username, $password, $msg)) {
					Show::notice('登陆成功，进行跳转', url('main'));
				}
				else {
					Show::warning($msg);
				}
			}
			else {
				Show::warning('输入用户名和密码');
			}
		}
                //$this->assign('msg',var_dump($_SESSION));
		$this->display();
	}

	public function logout() {
		UserAuthHelper::doLogout();
		$this->redirect();
	}

	public function proof(){
		ProofHelper::draw();
	}

	public function test(){
		$act = substr($_REQUEST['q'], strlen($_REQUEST['a'])+1);
		core::action('test', $act ?: 'show');
	}

	public function jvar() {
        header('Cache-Control: private, max-age='. 3000);
        header('Expires: '. date('r', time()+3000));
        header('Pragma: cache');
        $this->display();
        die;
	}
	
	/** 显示提示信息页面 */
	public function notice($msg, $jump, $timeout){
		View::assign(array('msg'=>$msg, 'jump'=>$jump, 'timeout'=>$timeout));
		View::display('pub-notice');
	}
        
        public function updatelogin()
        {
            if(UserAuthHelper::isLogin())
            {
                UserAuthHelper::updateLoginTime($_SESSION['UID']);
            }
           $this->display();
            die;
        }
	
}

?>
